package com.digitalchina.lxnsy.activity.old;


import android.os.Bundle;
import android.widget.TextView;

import com.ccj.poptabview.FilterConfig;
import com.ccj.poptabview.PopTabView;
import com.ccj.poptabview.base.BaseFilterTabBean;
import com.ccj.poptabview.bean.FilterGroup;
import com.ccj.poptabview.bean.FilterTabBean;
import com.ccj.poptabview.listener.OnPopTabSetListener;
import com.ccj.poptabview.loader.PopEntityLoaderImp;
import com.ccj.poptabview.loader.ResultLoaderImp;
import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;


/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.activity
 * 创建人：郑皓
 * 创建时间：2018/1/9 17:29
 * 修改备注：
 * ================================================
 */
public class FilterExpertListActivity extends BaseActivity implements OnPopTabSetListener<String> {


    @Bind(R.id.expand_pop)
    PopTabView expandPop;
    @Bind(R.id.tv_content)
    TextView tvContent;

    @Override
    public void setLayout() {
        setContentLayout(R.layout.activity_filter_expert_list);
        setTitle("测试");
    }

    @Override
    public void initMember() {

        addMyMethod();
    }

    private void addMyMethod() {

        FilterGroup filterGroup1 = getMyData("筛选1", FilterConfig.TYPE_POPWINDOW_ROWS, FilterConfig.FILTER_TYPE_SINGLE);
        FilterGroup filterGroup2 = getMyData("筛选2", FilterConfig.TYPE_POPWINDOW_LINKED, FilterConfig.FILTER_TYPE_SINGLE);
        FilterGroup filterGroup3 = getMyData("筛选3", FilterConfig.TYPE_POPWINDOW_SINGLE, FilterConfig.FILTER_TYPE_SINGLE);
        FilterGroup filterGroup4 = getMyData("筛选4", FilterConfig.TYPE_POPWINDOW_SORT, FilterConfig.FILTER_TYPE_SINGLE);

        expandPop.setOnPopTabSetListener(this)
                .setPopEntityLoader(new PopEntityLoaderImp()).setResultLoader(new ResultLoaderImp()) //配置 {筛选类型}  方式
                .addFilterItem(filterGroup1.getTab_group_name(), filterGroup1.getFilter_tab(), filterGroup1.getTab_group_type(), filterGroup1.getSingle_or_mutiply())
                .addFilterItem(filterGroup2.getTab_group_name(), filterGroup2.getFilter_tab(), filterGroup2.getTab_group_type(), filterGroup2.getSingle_or_mutiply())
                .addFilterItem(filterGroup3.getTab_group_name(), filterGroup3.getFilter_tab(), filterGroup3.getTab_group_type(), filterGroup3.getSingle_or_mutiply())
                .addFilterItem(filterGroup4.getTab_group_name(), filterGroup4.getFilter_tab(), filterGroup4.getTab_group_type(), filterGroup4.getSingle_or_mutiply());
        expandPop.setClickedItem(2, 0);
    }

    @Override
    public void addListener() {

    }

    @Override
    public void setHandler() {

    }

    @Override
    public void callBack(Object object) {

    }

    @Override
    public void rightOnClick() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    /**
     * 模拟数据
     * 筛选器的 数据格式 都是大同小异
     *
     * @return
     */
    public FilterGroup getMyData(String groupName, int groupType, int singleOrMutiply) {

        FilterGroup filterGroup = new FilterGroup();

        filterGroup.setTab_group_name(groupName);
        filterGroup.setTab_group_type(groupType);
        filterGroup.setSingle_or_mutiply(singleOrMutiply);


        List<BaseFilterTabBean> singleFilterList = new ArrayList<>();
        for (int i = 0; i < 8; i++) {//一级filter
            FilterTabBean singleFilterBean = new FilterTabBean();
            singleFilterBean.setTab_id("id" + "_" + i);
            singleFilterBean.setTab_name(groupName + "_" + i);

            List<FilterTabBean.ChildTabBean> childFilterList = new ArrayList<>();
            for (int j = 0; j < 5; j++) {//二级filter
                FilterTabBean.ChildTabBean secondFilterBean = new FilterTabBean.ChildTabBean();
                secondFilterBean.setTab_id("id" + "_" + i + "__" + j);
                secondFilterBean.setTab_name(groupName + "_" + i + "__" + j);
                childFilterList.add(secondFilterBean);
            }

            singleFilterBean.setTabs(childFilterList);
            singleFilterList.add(singleFilterBean);
        }

        filterGroup.setFilter_tab(singleFilterList);
        return filterGroup;

    }

    @Override
    public void onPopTabSet(int index, String lable, String params, String value) {
        tvContent.setText("&筛选项=" + index + "\n&筛选传参=" + params + "\n&筛选值=" + value);
    }
}
